/**
 * Created by ayu on 2017/6/29.
 */
let sqlExcute = require ('../utils/DB/MysqlStatement');

module.exports = {
    insertWechaterAccessToken: function ( param, callBack )
    {
        let sql = 'REPLACE INTO wechat_oauth_token (openid, access_token, refresh_token,expires_in,scope,create_at) values(?,?,?,?,?,?)';
        let arr = [ param.openid, param.access_token,param.refresh_token,param.expires_in,param.scope,param.create_at ];
        sqlExcute.sqlStatement ([ sql, arr ], function ( done )
        {
            if (done.isSuccess)
            {
                callBack ({
                    isSuccess: true
                });
            }
            else
            {
                callBack ({
                    isSuccess: false
                });
            }
        });
    },
    findWechaterAccessToken: function ( param,callBack )
    {
        let sql = 'SELECT * FROM wechat_access_token where id = ?';
        let arr = [ 1 ];
        sqlExcute.sqlStatement ([ sql, arr ], function ( done )
        {
            if (done.isSuccess)
            {
                callBack ({
                    isSuccess: true,
                    result   : done.result
                });
            }
            else
            {
                callBack ({
                    isSuccess: false
                });
            }
        });
    }
};